package com.cloud.code.leetcode;

public class Demo9 {

    public static void main(String[] args) {

    }


    public int maxProfit(int[] prices) {
        int max = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < prices.length; i++) {
            max = Math.max(max,prices[i]-min);
            min = Math.min(min,prices[i]);
        }

        return max;
    }
}
